<template>
	<view class="xzfx-panel" :class="{card: isCard}" :style="{backgroundColor: bgColor}">
		<view v-if="showTitle" class="panel-title">
			<view class="panel-name">
				<text v-if="icon" class="icon" :class="icon"></text>
				<text :class="{colourUnderline: showTitleColourUnderline}">{{ title }}</text>
				<text v-if="subTitle" class="panel-sub-name">{{ subTitle }}</text>
			</view>
			<slot name="action">
				<view v-if="showMore" class="panel-more" @click="$emit('more')">
					<text>更多</text>
					<text class="xzfx_icon_arrow_right"></text>
				</view>
			</slot>
		</view>
		<view>
			<slot name="content"></slot>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			title: {
				type: String,
				default: "卡片面板"
			},
			icon: {
				type: String,
				default: ""
			},
			subTitle: {
				type: String,
				default: ""
			},
			showTitle: {
				type: Boolean,
				default: true
			},
			showTitleColourUnderline: {
				type: Boolean,
				default: true
			},
			showMore: {
				type: Boolean,
				default: false
			},
			isCard: {
				type: Boolean,
				default: false
			},
			bgColor: {
				type: String,
				default: "#ffffff"
			}
		}
	}
</script>

<style lang="scss" scoped>
	.xzfx-panel {
		padding: 0 $xzfx-spacing;
		.panel-title{
			display: flex;
			justify-content: space-between;
			align-items: center;
			.panel-name{
				font-size: 34rpx;
				font-weight: bold;
				color: #333;
				.icon{
					font-size: 36rpx;
					margin-right: 7rpx;
				}
				.panel-sub-name{
					font-size: 26rpx;
					font-weight: 500;
					margin-left: 10rpx;
					color: #999999;
				}
			}
			.colourUnderline{
				position: relative;
				display: inline-block;
			}
			.colourUnderline::after{
				position: absolute;
				bottom: -5rpx;
				left: 0;
				content: "";
				width: 100%;
				height: 8rpx;
				border-radius: 8rpx;
				background: linear-gradient(90deg, #EA4070 0%, rgba(234,64,112,0.46) 100%);
			}
			.panel-more {
				display: flex;
				align-items: center;
				text {
					color: #666;
					font-size: 26rpx;
				}
			}
		}
	}
	.card{
		margin: $xzfx-spacing;
		border-radius: 20rpx;
		padding-top: $xzfx-spacing;
	}
</style>